package behavioral.command;

import behavioral.command.editor.BoldCommand;
import behavioral.command.editor.History;
import behavioral.command.editor.HtmlDocument;
import behavioral.command.editor.UndoCommand;

public class CommandPattern {
//    public static void main(String[] args) {
//        // Create a customer service
//        CustomerService customerService = new CustomerService();
//
//        // Create a command to add a customer
//        Command addCustomerCommand = new AddCustomerCommand(customerService);
//
//        // Create a button with the command
//        Button button = new Button(addCustomerCommand);
//
//        // Simulate button click
//        button.click();
//    }

//    public static void main(String[] args) {
//        CompositeCommand compositeCommand = new CompositeCommand();
//
//        compositeCommand.addCommand(new AddCustomerCommand(new CustomerService()));
//        compositeCommand.addCommand(new ResizeCommand());
//        compositeCommand.addCommand(new BlackAndWriteCommand());
//
//        Button button = new Button(compositeCommand);
//        button.click();
//    }

    // 模拟撤销操作
    public static void main(String[] args) {
        var document = new HtmlDocument("Hello");
        var history = new History();

        BoldCommand boldCommand = new BoldCommand(document, history);
        boldCommand.execute();
        System.out.println(document.getContent());


        UndoCommand undoCommand = new UndoCommand(history);
        undoCommand.execute();
        System.out.println(document.getContent());
    }
}
